package c.e.a.b.f.b;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import c.e.a.b.b.j.c;
import c.e.a.b.e.c.a1;
import c.e.a.b.e.c.c1;
import c.e.a.b.e.c.c1.a;
import c.e.a.b.e.c.d1;
import c.e.a.b.e.c.d6;
import c.e.a.b.e.c.e1;
import c.e.a.b.e.c.e5;
import c.e.a.b.e.c.g1;
import c.e.a.b.e.c.h1;
import c.e.a.b.e.c.h4;
import c.e.a.b.e.c.i1;
import c.e.a.b.e.c.i2;
import c.e.a.b.e.c.m0;
import c.e.a.b.e.c.n0;
import c.e.a.b.e.c.n3;
import c.e.a.b.e.c.o0;
import c.e.a.b.e.c.p0;
import c.e.a.b.e.c.s4;
import c.e.a.b.e.c.s5;
import c.e.a.b.e.c.u4;
import c.e.a.b.e.c.u4.b;
import c.e.a.b.e.c.y0;
import c.e.a.b.e.c.y1;
import c.e.a.b.e.c.z0;
import com.google.android.gms.measurement.internal.zzap;
import com.google.android.gms.measurement.internal.zzaq;
import com.google.android.gms.measurement.internal.zzn;
import com.huawei.hms.jos.games.ranking.RankingConst;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

/* compiled from: com.google.android.gms:play-services-measurement@@18.0.0 */
public final class q9 extends i9 {
    public q9(k9 k9Var) {
        super(k9Var);
    }

    public static String A(boolean z, boolean z2, boolean z3) {
        StringBuilder stringBuilder = new StringBuilder();
        if (z) {
            stringBuilder.append("Dynamic ");
        }
        if (z2) {
            stringBuilder.append("Sequence ");
        }
        if (z3) {
            stringBuilder.append("Session-Scoped ");
        }
        return stringBuilder.toString();
    }

    public static List<Long> B(BitSet bitSet) {
        int length = (bitSet.length() + 63) / 64;
        ArrayList arrayList = new ArrayList(length);
        for (int i = 0; i < length; i++) {
            long j = 0;
            for (int i2 = 0; i2 < 64; i2++) {
                int i3 = (i << 6) + i2;
                if (i3 >= bitSet.length()) {
                    break;
                }
                if (bitSet.get(i3)) {
                    j |= 1 << i2;
                }
            }
            arrayList.add(Long.valueOf(j));
        }
        return arrayList;
    }

    public static List<c1> D(Bundle[] bundleArr) {
        ArrayList arrayList = new ArrayList();
        for (Bundle bundle : bundleArr) {
            if (bundle != null) {
                a Q = c1.Q();
                for (String str : bundle.keySet()) {
                    a Q2 = c1.Q();
                    Q2.o(str);
                    Object obj = bundle.get(str);
                    if (obj instanceof Long) {
                        Q2.n(((Long) obj).longValue());
                    } else if (obj instanceof String) {
                        Q2.p((String) obj);
                    } else if (obj instanceof Double) {
                        Q2.m(((Double) obj).doubleValue());
                    }
                    if (Q.c) {
                        Q.j();
                        Q.c = false;
                    }
                    c1.x((c1) Q.b, (c1) ((u4) Q2.l()));
                }
                if (((c1) Q.b).P() > 0) {
                    arrayList.add((c1) ((u4) Q.l()));
                }
            }
        }
        return arrayList;
    }

    public static void E(a1.a aVar, String str, Object obj) {
        List s = aVar.s();
        int i = 0;
        while (i < s.size()) {
            if (str.equals(((c1) s.get(i)).B())) {
                break;
            }
            i++;
        }
        i = -1;
        a Q = c1.Q();
        Q.o(str);
        if (obj instanceof Long) {
            Q.n(((Long) obj).longValue());
        } else if (obj instanceof String) {
            Q.p((String) obj);
        } else if (obj instanceof Double) {
            Q.m(((Double) obj).doubleValue());
        } else if (obj instanceof Bundle[]) {
            List D = D((Bundle[]) obj);
            if (Q.c) {
                Q.j();
                Q.c = false;
            }
            c1.y((c1) Q.b, D);
        }
        if (i >= 0) {
            if (aVar.c) {
                aVar.j();
                aVar.c = false;
            }
            a1.y((a1) aVar.b, i, (c1) ((u4) Q.l()));
            return;
        }
        aVar.o(Q);
    }

    public static void H(StringBuilder stringBuilder, int i) {
        for (int i2 = 0; i2 < i; i2++) {
            stringBuilder.append("  ");
        }
    }

    public static void J(StringBuilder stringBuilder, int i, String str, n0 n0Var) {
        if (n0Var != null) {
            H(stringBuilder, i);
            stringBuilder.append(str);
            stringBuilder.append(" {\n");
            if (n0Var.u()) {
                L(stringBuilder, i, "comparison_type", n0Var.v().name());
            }
            if (n0Var.w()) {
                L(stringBuilder, i, "match_as_float", Boolean.valueOf(n0Var.x()));
            }
            if (n0Var.y()) {
                L(stringBuilder, i, "comparison_value", n0Var.z());
            }
            if (n0Var.A()) {
                L(stringBuilder, i, "min_comparison_value", n0Var.B());
            }
            if (n0Var.C()) {
                L(stringBuilder, i, "max_comparison_value", n0Var.D());
            }
            H(stringBuilder, i);
            stringBuilder.append("}\n");
        }
    }

    public static void K(StringBuilder stringBuilder, int i, String str, g1 g1Var) {
        if (g1Var != null) {
            int i2;
            int i3;
            int i4;
            H(stringBuilder, 3);
            stringBuilder.append(str);
            stringBuilder.append(" {\n");
            String str2 = ", ";
            if (g1Var.G() != 0) {
                H(stringBuilder, 4);
                stringBuilder.append("results: ");
                i2 = 0;
                for (Long l : g1Var.E()) {
                    i3 = i2 + 1;
                    if (i2 != 0) {
                        stringBuilder.append(str2);
                    }
                    stringBuilder.append(l);
                    i2 = i3;
                }
                stringBuilder.append(10);
            }
            if (g1Var.z() != 0) {
                H(stringBuilder, 4);
                stringBuilder.append("status: ");
                i2 = 0;
                for (Long l2 : g1Var.v()) {
                    i3 = i2 + 1;
                    if (i2 != 0) {
                        stringBuilder.append(str2);
                    }
                    stringBuilder.append(l2);
                    i2 = i3;
                }
                stringBuilder.append(10);
            }
            String str3 = "}\n";
            if (g1Var.J() != 0) {
                H(stringBuilder, 4);
                stringBuilder.append("dynamic_filter_timestamps: {");
                i4 = 0;
                for (z0 z0Var : g1Var.I()) {
                    int i5 = i4 + 1;
                    if (i4 != 0) {
                        stringBuilder.append(str2);
                    }
                    stringBuilder.append(z0Var.w() ? Integer.valueOf(z0Var.x()) : null);
                    stringBuilder.append(":");
                    stringBuilder.append(z0Var.y() ? Long.valueOf(z0Var.z()) : null);
                    i4 = i5;
                }
                stringBuilder.append(str3);
            }
            if (g1Var.L() != 0) {
                H(stringBuilder, 4);
                stringBuilder.append("sequence_filter_timestamps: {");
                int i6 = 0;
                for (h1 h1Var : g1Var.K()) {
                    i4 = i6 + 1;
                    if (i6 != 0) {
                        stringBuilder.append(str2);
                    }
                    stringBuilder.append(h1Var.x() ? Integer.valueOf(h1Var.y()) : null);
                    stringBuilder.append(": [");
                    int i7 = 0;
                    for (Long longValue : h1Var.z()) {
                        long longValue2 = longValue.longValue();
                        int i8 = i7 + 1;
                        if (i7 != 0) {
                            stringBuilder.append(str2);
                        }
                        stringBuilder.append(longValue2);
                        i7 = i8;
                    }
                    stringBuilder.append("]");
                    i6 = i4;
                }
                stringBuilder.append(str3);
            }
            H(stringBuilder, 3);
            stringBuilder.append(str3);
        }
    }

    public static void L(StringBuilder stringBuilder, int i, String str, Object obj) {
        if (obj != null) {
            H(stringBuilder, i + 1);
            stringBuilder.append(str);
            stringBuilder.append(": ");
            stringBuilder.append(obj);
            stringBuilder.append(10);
        }
    }

    public static boolean O(zzaq zzaq, zzn zzn) {
        Objects.requireNonNull(zzaq, "null reference");
        return (TextUtils.isEmpty(zzn.b) && TextUtils.isEmpty(zzn.r)) ? false : true;
    }

    public static boolean P(String str) {
        return str != null && str.matches("([+-])?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)") && str.length() <= 310;
    }

    public static boolean Q(List<Long> list, int i) {
        if (i < (((s5) list).c << 6)) {
            if (((1 << (i % 64)) & ((Long) ((s5) list).get(i / 64)).longValue()) != 0) {
                return true;
            }
        }
        return false;
    }

    public static Object R(a1 a1Var, String str) {
        c1 w = w(a1Var, str);
        if (w != null) {
            if (w.F()) {
                return w.G();
            }
            if (w.I()) {
                return Long.valueOf(w.J());
            }
            if (w.M()) {
                return Double.valueOf(w.N());
            }
            if (w.P() > 0) {
                List<c1> O = w.O();
                ArrayList arrayList = new ArrayList();
                for (c1 c1Var : O) {
                    if (c1Var != null) {
                        Bundle bundle = new Bundle();
                        for (c1 c1Var2 : c1Var.O()) {
                            if (c1Var2.F()) {
                                bundle.putString(c1Var2.B(), c1Var2.G());
                            } else if (c1Var2.I()) {
                                bundle.putLong(c1Var2.B(), c1Var2.J());
                            } else if (c1Var2.M()) {
                                bundle.putDouble(c1Var2.B(), c1Var2.N());
                            }
                        }
                        if (!bundle.isEmpty()) {
                            arrayList.add(bundle);
                        }
                    }
                }
                return (Bundle[]) arrayList.toArray(new Bundle[arrayList.size()]);
            }
        }
        return null;
    }

    public static int s(e1.a aVar, String str) {
        for (int i = 0; i < ((e1) aVar.b).P0(); i++) {
            if (str.equals(((e1) aVar.b).h0(i).D())) {
                return i;
            }
        }
        return -1;
    }

    public static c1 w(a1 a1Var, String str) {
        for (c1 c1Var : a1Var.v()) {
            if (c1Var.B().equals(str)) {
                return c1Var;
            }
        }
        return null;
    }

    public static <Builder extends d6> Builder x(Builder builder, byte[] bArr) throws e5 {
        Class cls = h4.class;
        h4 h4Var = h4.c;
        if (h4Var == null) {
            synchronized (cls) {
                h4Var = h4.c;
                if (h4Var != null) {
                } else {
                    h4Var = s4.b(cls);
                    h4.c = h4Var;
                }
            }
        }
        n3 n3Var;
        b bVar;
        if (h4Var != null) {
            n3Var = (n3) builder;
            Objects.requireNonNull(n3Var);
            bVar = (b) n3Var;
            bVar.i(bArr, bArr.length, h4Var);
            return bVar;
        }
        n3Var = (n3) builder;
        Objects.requireNonNull(n3Var);
        bVar = (b) n3Var;
        bVar.i(bArr, bArr.length, h4.a());
        return bVar;
    }

    public final List<Long> C(List<Long> list, List<Integer> list2) {
        ArrayList arrayList = new ArrayList(list);
        for (Integer num : list2) {
            if (num.intValue() < 0) {
                d().i.b("Ignoring negative bit index to be cleared", num);
            } else {
                int intValue = num.intValue() / 64;
                if (intValue >= arrayList.size()) {
                    d().i.c("Ignoring bit index greater than bitSet size", num, Integer.valueOf(arrayList.size()));
                } else {
                    arrayList.set(intValue, Long.valueOf(((Long) arrayList.get(intValue)).longValue() & (~(1 << (num.intValue() % 64)))));
                }
            }
        }
        int size = arrayList.size();
        int size2 = arrayList.size() - 1;
        while (true) {
            int i = size2;
            size2 = size;
            size = i;
            if (size >= 0 && ((Long) arrayList.get(size)).longValue() == 0) {
                size2 = size - 1;
            }
        }
        return arrayList.subList(0, size2);
    }

    public final void F(a aVar, Object obj) {
        Objects.requireNonNull(obj, "null reference");
        if (aVar.c) {
            aVar.j();
            aVar.c = false;
        }
        c1.u((c1) aVar.b);
        if (aVar.c) {
            aVar.j();
            aVar.c = false;
        }
        c1.C((c1) aVar.b);
        if (aVar.c) {
            aVar.j();
            aVar.c = false;
        }
        c1.E((c1) aVar.b);
        if (aVar.c) {
            aVar.j();
            aVar.c = false;
        }
        c1.H((c1) aVar.b);
        if (obj instanceof String) {
            aVar.p((String) obj);
        } else if (obj instanceof Long) {
            aVar.n(((Long) obj).longValue());
        } else if (obj instanceof Double) {
            aVar.m(((Double) obj).doubleValue());
        } else if (obj instanceof Bundle[]) {
            List D = D((Bundle[]) obj);
            if (aVar.c) {
                aVar.j();
                aVar.c = false;
            }
            c1.y((c1) aVar.b, D);
        } else {
            d().f.b("Ignoring invalid (type) event param value", obj);
        }
    }

    public final void G(i1.a aVar, Object obj) {
        Objects.requireNonNull(obj, "null reference");
        if (aVar.c) {
            aVar.j();
            aVar.c = false;
        }
        i1.u((i1) aVar.b);
        if (aVar.c) {
            aVar.j();
            aVar.c = false;
        }
        i1.A((i1) aVar.b);
        if (aVar.c) {
            aVar.j();
            aVar.c = false;
        }
        i1.E((i1) aVar.b);
        if (obj instanceof String) {
            String str = (String) obj;
            if (aVar.c) {
                aVar.j();
                aVar.c = false;
            }
            i1.C((i1) aVar.b, str);
        } else if (obj instanceof Long) {
            aVar.o(((Long) obj).longValue());
        } else if (obj instanceof Double) {
            double doubleValue = ((Double) obj).doubleValue();
            if (aVar.c) {
                aVar.j();
                aVar.c = false;
            }
            i1.v((i1) aVar.b, doubleValue);
        } else {
            d().f.b("Ignoring invalid (type) user attribute value", obj);
        }
    }

    public final void I(StringBuilder stringBuilder, int i, m0 m0Var) {
        if (m0Var != null) {
            H(stringBuilder, i);
            stringBuilder.append("filter {\n");
            if (m0Var.z()) {
                L(stringBuilder, i, "complement", Boolean.valueOf(m0Var.A()));
            }
            if (m0Var.B()) {
                L(stringBuilder, i, "param_name", j().x(m0Var.C()));
            }
            String str = "}\n";
            if (m0Var.v()) {
                int i2 = i + 1;
                p0 w = m0Var.w();
                if (w != null) {
                    H(stringBuilder, i2);
                    stringBuilder.append("string_filter");
                    stringBuilder.append(" {\n");
                    if (w.u()) {
                        L(stringBuilder, i2, "match_type", w.v().name());
                    }
                    if (w.w()) {
                        L(stringBuilder, i2, "expression", w.x());
                    }
                    if (w.y()) {
                        L(stringBuilder, i2, "case_sensitive", Boolean.valueOf(w.z()));
                    }
                    if (w.B() > 0) {
                        H(stringBuilder, i2 + 1);
                        stringBuilder.append("expression_list {\n");
                        for (String str2 : w.A()) {
                            H(stringBuilder, i2 + 2);
                            stringBuilder.append(str2);
                            stringBuilder.append("\n");
                        }
                        stringBuilder.append(str);
                    }
                    H(stringBuilder, i2);
                    stringBuilder.append(str);
                }
            }
            if (m0Var.x()) {
                J(stringBuilder, i + 1, "number_filter", m0Var.y());
            }
            H(stringBuilder, i);
            stringBuilder.append(str);
        }
    }

    public final void M(StringBuilder stringBuilder, int i, List<c1> list) {
        if (list != null) {
            i++;
            for (c1 c1Var : list) {
                if (c1Var != null) {
                    H(stringBuilder, i);
                    stringBuilder.append("param {\n");
                    Object obj = null;
                    L(stringBuilder, i, RankingConst.RANKING_JGW_NAME, c1Var.A() ? j().x(c1Var.B()) : null);
                    L(stringBuilder, i, "string_value", c1Var.F() ? c1Var.G() : null);
                    L(stringBuilder, i, "int_value", c1Var.I() ? Long.valueOf(c1Var.J()) : null);
                    if (c1Var.M()) {
                        obj = Double.valueOf(c1Var.N());
                    }
                    L(stringBuilder, i, "double_value", obj);
                    if (c1Var.P() > 0) {
                        M(stringBuilder, i, c1Var.O());
                    }
                    H(stringBuilder, i);
                    stringBuilder.append("}\n");
                }
            }
        }
    }

    public final boolean N(long j, long j2) {
        if (j != 0 && j2 > 0) {
            Objects.requireNonNull((c) this.a.n);
            if (Math.abs(System.currentTimeMillis() - j) <= j2) {
                return false;
            }
        }
        return true;
    }

    public final byte[] S(byte[] bArr) throws IOException {
        try {
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bArr);
            GZIPInputStream gZIPInputStream = new GZIPInputStream(byteArrayInputStream);
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            byte[] bArr2 = new byte[1024];
            while (true) {
                int read = gZIPInputStream.read(bArr2);
                if (read > 0) {
                    byteArrayOutputStream.write(bArr2, 0, read);
                } else {
                    gZIPInputStream.close();
                    byteArrayInputStream.close();
                    return byteArrayOutputStream.toByteArray();
                }
            }
        } catch (IOException e) {
            d().f.b("Failed to ungzip content", e);
            throw e;
        }
    }

    public final byte[] T(byte[] bArr) throws IOException {
        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(byteArrayOutputStream);
            gZIPOutputStream.write(bArr);
            gZIPOutputStream.close();
            byteArrayOutputStream.close();
            return byteArrayOutputStream.toByteArray();
        } catch (IOException e) {
            d().f.b("Failed to gzip content", e);
            throw e;
        }
    }

    public final List<Integer> U() {
        Context context = this.b.j.a;
        List list = p.a;
        y1 b = y1.b(context.getContentResolver(), i2.a("com.google.android.gms.measurement"));
        Map emptyMap = b == null ? Collections.emptyMap() : b.c();
        if (emptyMap == null || emptyMap.size() == 0) {
            return null;
        }
        ArrayList arrayList = new ArrayList();
        int intValue = ((Integer) p.P.a(null)).intValue();
        for (Entry entry : emptyMap.entrySet()) {
            if (((String) entry.getKey()).startsWith("measurement.id.")) {
                try {
                    int parseInt = Integer.parseInt((String) entry.getValue());
                    if (parseInt != 0) {
                        arrayList.add(Integer.valueOf(parseInt));
                        if (arrayList.size() >= intValue) {
                            d().i.b("Too many experiment IDs. Number of IDs", Integer.valueOf(arrayList.size()));
                            break;
                        }
                    } else {
                        continue;
                    }
                } catch (NumberFormatException e) {
                    d().i.b("Experiment ID NumberFormatException", e);
                }
            }
        }
        if (arrayList.size() == 0) {
            return null;
        }
        return arrayList;
    }

    public final boolean p() {
        return false;
    }

    public final long t(byte[] bArr) {
        k().g();
        MessageDigest x0 = t9.x0();
        if (x0 != null) {
            return t9.w(x0.digest(bArr));
        }
        d().f.a("Failed to get MD5");
        return 0;
    }

    /* JADX WARNING: Missing exception handler attribute for start block: B:9:0x001c */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing block: B:10:?, code skipped:
            d().f.a("Failed to load parcelable from buffer");
     */
    /* JADX WARNING: Missing block: B:11:0x002a, code skipped:
            return null;
     */
    /* JADX WARNING: Missing block: B:12:0x002b, code skipped:
            r1.recycle();
     */
    public final <T extends android.os.Parcelable> T u(byte[] r5, android.os.Parcelable.Creator<T> r6) {
        /*
        r4 = this;
        r0 = 0;
        if (r5 != 0) goto L_0x0004;
    L_0x0003:
        return r0;
    L_0x0004:
        r1 = android.os.Parcel.obtain();
        r2 = r5.length;	 Catch:{ a -> 0x001c }
        r3 = 0;
        r1.unmarshall(r5, r3, r2);	 Catch:{ a -> 0x001c }
        r1.setDataPosition(r3);	 Catch:{ a -> 0x001c }
        r5 = r6.createFromParcel(r1);	 Catch:{ a -> 0x001c }
        r5 = (android.os.Parcelable) r5;	 Catch:{ a -> 0x001c }
        r1.recycle();
        return r5;
    L_0x001a:
        r5 = move-exception;
        goto L_0x002b;
    L_0x001c:
        r5 = r4.d();	 Catch:{ all -> 0x001a }
        r5 = r5.f;	 Catch:{ all -> 0x001a }
        r6 = "Failed to load parcelable from buffer";
        r5.a(r6);	 Catch:{ all -> 0x001a }
        r1.recycle();
        return r0;
    L_0x002b:
        r1.recycle();
        throw r5;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.e.a.b.f.b.q9.u(byte[], android.os.Parcelable$Creator):android.os.Parcelable");
    }

    public final a1 v(m mVar) {
        a1.a M = a1.M();
        long j = mVar.e;
        if (M.c) {
            M.j();
            M.c = false;
        }
        a1.E((a1) M.b, j);
        zzap zzap = mVar.f;
        Objects.requireNonNull(zzap);
        for (String str : zzap.a.keySet()) {
            a Q = c1.Q();
            Q.o(str);
            F(Q, mVar.f.b(str));
            M.o(Q);
        }
        return (a1) ((u4) M.l());
    }

    public final String y(o0 o0Var) {
        StringBuilder g = c.b.a.a.a.g("\nproperty_filter {\n");
        if (o0Var.v()) {
            L(g, 0, "filter_id", Integer.valueOf(o0Var.w()));
        }
        L(g, 0, "property_name", j().y(o0Var.x()));
        String A = A(o0Var.z(), o0Var.A(), o0Var.C());
        if (!A.isEmpty()) {
            L(g, 0, "filter_type", A);
        }
        I(g, 1, o0Var.y());
        g.append("}\n");
        return g.toString();
    }

    public final String z(d1 d1Var) {
        StringBuilder g = c.b.a.a.a.g("\nbatch {\n");
        Iterator it = d1Var.v().iterator();
        while (true) {
            String str = "}\n";
            if (it.hasNext()) {
                e1 e1Var = (e1) it.next();
                if (e1Var != null) {
                    H(g, 1);
                    g.append("bundle {\n");
                    if (e1Var.E()) {
                        L(g, 1, "protocol_version", Integer.valueOf(e1Var.g0()));
                    }
                    L(g, 1, "platform", e1Var.y1());
                    if (e1Var.I1()) {
                        L(g, 1, "gmp_version", Long.valueOf(e1Var.F()));
                    }
                    if (e1Var.H()) {
                        L(g, 1, "uploading_gmp_version", Long.valueOf(e1Var.I()));
                    }
                    if (e1Var.p0()) {
                        L(g, 1, "dynamite_version", Long.valueOf(e1Var.q0()));
                    }
                    if (e1Var.a0()) {
                        L(g, 1, "config_version", Long.valueOf(e1Var.b0()));
                    }
                    L(g, 1, "gmp_app_id", e1Var.S());
                    L(g, 1, "admob_app_id", e1Var.o0());
                    L(g, 1, HiAnalyticsConstant.BI_KEY_APP_ID, e1Var.G1());
                    L(g, 1, "app_version", e1Var.H1());
                    if (e1Var.X()) {
                        L(g, 1, "app_version_major", Integer.valueOf(e1Var.Y()));
                    }
                    L(g, 1, "firebase_instance_id", e1Var.W());
                    if (e1Var.N()) {
                        L(g, 1, "dev_cert_hash", Long.valueOf(e1Var.O()));
                    }
                    L(g, 1, "app_store", e1Var.F1());
                    if (e1Var.Y0()) {
                        L(g, 1, "upload_timestamp_millis", Long.valueOf(e1Var.Z0()));
                    }
                    if (e1Var.g1()) {
                        L(g, 1, "start_timestamp_millis", Long.valueOf(e1Var.h1()));
                    }
                    if (e1Var.n1()) {
                        L(g, 1, "end_timestamp_millis", Long.valueOf(e1Var.o1()));
                    }
                    if (e1Var.s1()) {
                        L(g, 1, "previous_bundle_start_timestamp_millis", Long.valueOf(e1Var.t1()));
                    }
                    if (e1Var.v1()) {
                        L(g, 1, "previous_bundle_end_timestamp_millis", Long.valueOf(e1Var.w1()));
                    }
                    L(g, 1, "app_instance_id", e1Var.M());
                    L(g, 1, "resettable_device_id", e1Var.J());
                    L(g, 1, "device_id", e1Var.Z());
                    L(g, 1, "ds_id", e1Var.e0());
                    if (e1Var.K()) {
                        L(g, 1, "limited_ad_tracking", Boolean.valueOf(e1Var.L()));
                    }
                    L(g, 1, "os_version", e1Var.A1());
                    L(g, 1, "device_model", e1Var.B1());
                    L(g, 1, "user_default_language", e1Var.C1());
                    if (e1Var.D1()) {
                        L(g, 1, "time_zone_offset_minutes", Integer.valueOf(e1Var.E1()));
                    }
                    if (e1Var.P()) {
                        L(g, 1, "bundle_sequential_index", Integer.valueOf(e1Var.Q()));
                    }
                    if (e1Var.T()) {
                        L(g, 1, "service_upload", Boolean.valueOf(e1Var.U()));
                    }
                    L(g, 1, "health_monitor", e1Var.R());
                    if (!(this.a.g.o(p.y0) || !e1Var.c0() || e1Var.d0() == 0)) {
                        L(g, 1, "android_id", Long.valueOf(e1Var.d0()));
                    }
                    if (e1Var.f0()) {
                        L(g, 1, "retry_counter", Integer.valueOf(e1Var.n0()));
                    }
                    if (e1Var.s0()) {
                        L(g, 1, "consent_signals", e1Var.t0());
                    }
                    List<i1> K0 = e1Var.K0();
                    String str2 = RankingConst.RANKING_JGW_NAME;
                    if (K0 != null) {
                        for (i1 i1Var : K0) {
                            if (i1Var != null) {
                                H(g, 2);
                                g.append("user_property {\n");
                                Object obj = null;
                                L(g, 2, "set_timestamp_millis", i1Var.y() ? Long.valueOf(i1Var.z()) : null);
                                L(g, 2, str2, j().y(i1Var.D()));
                                L(g, 2, "string_value", i1Var.G());
                                L(g, 2, "int_value", i1Var.H() ? Long.valueOf(i1Var.I()) : null);
                                if (i1Var.J()) {
                                    obj = Double.valueOf(i1Var.K());
                                }
                                L(g, 2, "double_value", obj);
                                H(g, 2);
                                g.append(str);
                            }
                        }
                    }
                    List<y0> V = e1Var.V();
                    if (V != null) {
                        for (y0 y0Var : V) {
                            if (y0Var != null) {
                                H(g, 2);
                                g.append("audience_membership {\n");
                                if (y0Var.x()) {
                                    L(g, 2, "audience_id", Integer.valueOf(y0Var.y()));
                                }
                                if (y0Var.D()) {
                                    L(g, 2, "new_audience", Boolean.valueOf(y0Var.E()));
                                }
                                K(g, 2, "current_data", y0Var.A());
                                if (y0Var.B()) {
                                    K(g, 2, "previous_data", y0Var.C());
                                }
                                H(g, 2);
                                g.append(str);
                            }
                        }
                    }
                    List<a1> y0 = e1Var.y0();
                    if (y0 != null) {
                        for (a1 a1Var : y0) {
                            if (a1Var != null) {
                                H(g, 2);
                                g.append("event {\n");
                                L(g, 2, str2, j().u(a1Var.F()));
                                if (a1Var.G()) {
                                    L(g, 2, "timestamp_millis", Long.valueOf(a1Var.H()));
                                }
                                if (a1Var.I()) {
                                    L(g, 2, "previous_timestamp_millis", Long.valueOf(a1Var.J()));
                                }
                                if (a1Var.K()) {
                                    L(g, 2, RankingConst.RANKING_SDK_COUNT, Integer.valueOf(a1Var.L()));
                                }
                                if (a1Var.D() != 0) {
                                    M(g, 2, a1Var.v());
                                }
                                H(g, 2);
                                g.append(str);
                            }
                        }
                    }
                    H(g, 1);
                    g.append(str);
                }
            } else {
                g.append(str);
                return g.toString();
            }
        }
    }
}
